# MixVideo Makefile

.PHONY: help install install-dev test test-unit test-integration lint format type-check clean build run-gui run-server run-cli docs

# 默认目标
help:
	@echo "MixVideo 开发工具"
	@echo ""
	@echo "可用命令:"
	@echo "  install        安装项目依赖"
	@echo "  install-dev    安装开发依赖"
	@echo "  test           运行所有测试"
	@echo "  test-unit      运行单元测试"
	@echo "  test-integration 运行集成测试"
	@echo "  lint           代码检查"
	@echo "  format         代码格式化"
	@echo "  type-check     类型检查"
	@echo "  clean          清理临时文件"
	@echo "  build          构建项目"
	@echo "  run-gui        启动GUI界面"
	@echo "  run-server     启动Web服务器"
	@echo "  run-cli        运行CLI工具"
	@echo "  docs           生成文档"

# 安装依赖
install:
	pip install -e .

install-dev:
	pip install -e .[dev]
	pre-commit install

# 测试
test:
	pytest

test-unit:
	pytest tests/unit/

test-integration:
	pytest tests/integration/

test-cov:
	pytest --cov=mixvideo --cov-report=html --cov-report=term

# 代码质量
lint:
	flake8 src/ tests/
	mypy src/

format:
	black src/ tests/
	isort src/ tests/

type-check:
	mypy src/

# 清理
clean:
	find . -type f -name "*.pyc" -delete
	find . -type d -name "__pycache__" -delete
	find . -type d -name "*.egg-info" -exec rm -rf {} +
	rm -rf build/
	rm -rf dist/
	rm -rf .coverage
	rm -rf htmlcov/
	rm -rf .pytest_cache/
	rm -rf .mypy_cache/

# 构建
build:
	python -m build

# 运行应用
run-gui:
	python -m src.interfaces.gui

run-server:
	python -m src.interfaces.web

run-cli:
	python -m src.interfaces.cli --help

# 文档
docs:
	@echo "文档生成功能待实现"

# 开发环境设置
setup-dev: install-dev
	cp config/config.example.yaml config/config.yaml
	cp .env.example .env
	@echo "开发环境设置完成！"
	@echo "请编辑 config/config.yaml 和 .env 文件配置您的环境"

# 检查环境
check-env:
	@echo "检查Python版本..."
	@python --version
	@echo "检查FFmpeg..."
	@ffmpeg -version | head -1 || echo "警告: FFmpeg未安装"
	@echo "检查依赖..."
	@pip check

# 全面检查
check-all: lint type-check test

# 发布准备
release-check: clean check-all build
	@echo "发布检查完成"
